package Demo2;

import javax.jws.soap.SOAPBinding;

/**
 * Created with Interllij IDEA.
 * Descriptiption:
 * User: 王澄慧
 * Date: 2022-04-09
 * Time: 11:23
 */
class Annimals {
    String name;
    public Annimals(String name) {
        this.name = name;
    }
}
    interface Isflying {
        void fly();
   }
   interface ISrunning {
        void run();
    }

    interface ISswniming {
        void swinm();
    }

    class Dog extends Annimals implements ISrunning, ISswniming {
        public Dog(String name) {
            super(name);
        }

        @Override
        public void run() {

            System.out.println(this.name + "正在跑！");
        }

        @Override
        public void swinm() {

            System.out.println(this.name + "正在游泳！");
        }
    }
    class Cat extends Annimals implements ISrunning{
    public Cat (String name){
        super(name);
    }

        @Override
        public void run() {
            System.out.println(this.name+"正在跑");
        }
    }
    class Duck extends Annimals implements ISrunning,ISswniming,Isflying{
    public Duck (String name){
        super(name);
    }

        @Override
        public void fly() {
            System.out.println(this.name+"正在飞");
        }

        @Override
        public void run() {
            System.out.println(this.name+"正在跑");
        }

        @Override
        public void swinm() {
            System.out.println(this.name+"正在游泳");
        }
    }

    public class test1 {
    public static void work(ISrunning iSrunning) {
        iSrunning.run();
    }
    public static void swimi(ISswniming iSswniming){
        iSswniming.swinm();
    }
        public static void fly(Isflying isflying){
            isflying.fly();
        }
        public static void main(String[] args) {
        Dog dog = new Dog("lala");
        Cat cat = new Cat("mimi");
        Duck duck = new Duck("haha");
        fly(duck);
        work(dog);
        work(cat);
        swimi(dog);
        }

        public static void main1(String[] args) {
            Annimals annimals = new Dog("lala");
            Annimals annimals1 = new Cat("mimi");
            ISrunning iSrunning = new Dog("lala");
            ISswniming iSswniming = new Dog("lala");
            ISrunning iSrunning1 = new Cat("mimi");

        }


}

